package com.ysq.www.api.user.controller;


import com.ysq.www.api.user.service.IGiveLikeService;
import com.ysq.www.common.annotation.AuthToken;
import com.ysq.www.common.result.ResultMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 点赞记录表 前端控制器
 * </p>
 *
 * @author dql
 * @since 2020-09-07
 */
@RestController
@RequestMapping("/user/giveLike")
public class GiveLikeController {

    @Autowired
    private IGiveLikeService giveLikeService;

    /**
     * 点赞/取消点赞
     * @param userId 用户id
     * @param contentId 内容id
     * @param type 点赞类型：1资讯
     * @param isLike 0取消点赞，1点赞
     * @return ResultMsg
     */
    @GetMapping("/addOrUpdate")
    @AuthToken
    public ResultMsg addOrUpdateById(@RequestParam(required = true) Integer userId,
                                     @RequestParam(required = true) Integer contentId,
                                     @RequestParam(required = true) Integer type,
                                     @RequestParam(required = true) Integer isLike){
        ResultMsg rm = giveLikeService.addOrUpdateById(userId,contentId,type,isLike);
        return rm;
    }


}
